<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>微信公众号信息管理</title>
<%@ include file="../../common/importLib.jsp" %>
<script type="text/javascript" src="../../common/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="../../common/js/CityJs/jquery.cityselect.js"></script>
<script type="text/javascript">
$(function(){	
	$.post("weixinAccount/queryBySchoolId.do",function(data) {
		if(data && data != null) {
			$('#id').val(data.id);
			$('#schoolId').val(data.schoolId);
			$('#account').val(data.account);
			$('#appid').val(data.appid);
			$('#appsecret').val(data.appsecret);
			$('#token').val(data.token);
		}else{
			$('#update_form').attr('action','weixinAccount/add.do');
		}
		formProcessForTime("appid","公众号");	
		ajaxFormValidator("account","账号",1,30,"weixinAccount/accountValidate.do","letter");
		baseFormValidator("appid","APPID",1,50,"username");
		baseFormValidator("appsecret","APPSECRET",1,50,"username");
		baseFormValidator("token","TOKEN",1,36,"username");
	});
});   
function formProcessForTime(focusId,messagerFlag){
	$("#" + focusId).focus();
	var updateForm = $('#update_form');
	$.formValidator.initConfig({
		formID : updateForm.attr("id"),	
		submitOnce:true,	
		onSuccess : function() {
			$.post(updateForm.attr("action"),updateForm.serialize(),
				function(data){
					if(data=="ok"){							
						$('#datagrid_update').window('close');  //关闭修改窗口
						$.messager.alert("修改成功",messagerFlag + "修改成功！",'info');  //提示修改信息成功							
						$('#datagrid_table').datagrid('reload');
					}
					if(data.split("_")[0]=="uniqueValue"){
						formSubmitOnce = true;
						$.messager.alert("修改失败",data.split("_")[1] + "修改失败！",'info');  
					}
				},"json");
			return false;
		}
	});
}
</script>
</head>
<body>	
	<div>
		<form id="update_form" action="weixinAccount/updateById.do" method="post">
			<input type="hidden" id="id" name="id"/>
			<input type ="hidden" id="schoolId" name="schoolId">
			<table style="font-size: 12px" class="xxl_tb_1">
				<tbody>	
					<tr>
						<td class="xxl_td_2">账号标识：</td>
						<td><input type="text" id="account" name="account" style="width:250px" onchange="validateSubmitOnce=true"/></td>
						<td><div id="accountTip" style="width:250px"></div></td>
					</tr>
					<tr> 
						<td class="xxl_td_2">APP ID：</td>
						<td><input type="text" id="appid" name="appid" style="width:250px"/></td>
						<td><div id="appidTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">APP SECRET：</td>
						<td><input type="text" id="appsecret" name="appsecret" style="width:250px"/></td>
						<td><div id="appsecretTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">TOKEN：</td>
						<td><input type="text" id="token" name="token" style="width:250px"/></td>
						<td><div id="tokenTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td colspan="2" style="text-align: center">
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#update_form').submit();">修改</a>		
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
</body>
</html>